﻿package mortal.game.view.pack.social
{
    import com.mui.controls.*;
    import extend.language.*;
    import flash.events.*;
    import mortal.component.window.*;
    import mortal.game.events.*;
    import mortal.game.manager.*;
    import mortal.game.manager.msgTip.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.info.item.*;
    import mortal.game.view.common.*;
    import mortal.mvc.core.*;

    public class SplitTipWin extends SmallWindow
    {
        private var _textField:GTextFiled;
        private var _textInput:GTextInput;
        private var _btnOK:GButton;
        private var _btnCancel:GButton;
        private var _itemData:ItemData;
        private static var _instance:SplitTipWin;

        public function SplitTipWin()
        {
            this.setSize(240, 145);
            title = Language.getString(35491);
            if (_instance != null)
            {
                throw new Error(" SplitTipWin 单例 ");
            }
            return;
        }// end function

        public function showWin(param1:ItemData) : void
        {
            this._itemData = param1;
            _instance.show();
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._textField = UIFactory.gTextField("", 57, 47, 150, 20, this, null, true);
            this._textField.htmlText = "<font color=\'#ffffff\' size=\'13\'>" + Language.getString(30025) + "</font>";
            this._textInput = UIFactory.gTextInput(73, 73, 100, 24, this);
            this._textInput.restrict = "0-9";
            this._textInput.text = "1";
            this._btnOK = UIFactory.gButton(Language.getString(30026), 50, 105, 47, 22, this);
            this._btnOK.configEventListener(MouseEvent.CLICK, this.SplitHandler);
            this._btnCancel = UIFactory.gButton(Language.getString(30027), 150, 105, 47, 22, this);
            this._btnCancel.configEventListener(MouseEvent.CLICK, this.CloseHandler);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            this._textField.dispose(param1);
            this._textInput.dispose(param1);
            this._btnOK.dispose(param1);
            this._btnCancel.dispose(param1);
            this._textField = null;
            this._textInput = null;
            this._btnOK = null;
            this._btnCancel = null;
            super.disposeImpl(param1);
            return;
        }// end function

        private function SplitHandler(event:MouseEvent) : void
        {
            var _loc_2:* = int(this._textInput.text);
            if (_loc_2 > 0 && _loc_2 < this._itemData.serverData.itemAmount)
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.BackPack_Split, {uid:this._itemData.serverData.uid, amount:_loc_2}));
                this.hide();
            }
            else
            {
                MsgManager.showRollTipsMsg(Language.getString(35629), MsgRollTipsType.msgRollTips3);
            }
            return;
        }// end function

        private function CloseHandler(event:MouseEvent) : void
        {
            this.hide();
            return;
        }// end function

        public static function get instance() : SplitTipWin
        {
            if (_instance == null)
            {
                _instance = new SplitTipWin;
            }
            return _instance;
        }// end function

    }
}
